package tt.love.hw;

import java.io.IOException;
import java.util.Locale;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.jstl.core.Config;


public class LocaleFilter implements Filter {

   
    public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain ) throws IOException,ServletException {
           
            Locale locale = (Locale) ((HttpServletRequest)request).getSession().getAttribute("javax.servlet.jsp.jstl.fmt.locale");
            if(locale==null){
            	locale = new Locale("zh","CN");
            }
			response.setLocale(locale);
			Config.set(((HttpServletRequest)request).getSession(), "javax.servlet.jsp.jstl.fmt.locale", locale);
            chain.doFilter(request, response);        
      
    }

	public void destroy() {
		
	}

	public void init(FilterConfig arg0) throws ServletException {

	}
   
}
